﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    var version = Math.random();
    var operFid = "";
    var operOStatus = "";
    $(function () {
        gridList();
        $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center', 'vertical-align': 'middle','width': '50' });
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Gas/Apply/GetGridJson",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                @*{ label: "排位号", name: "ApplyNumber", width: 100, align: 'center' },*@
                { label: "注册手机号", name: "Phone", width: 100, align: 'left' },
                { label: "学生姓名", name: "StudentName", width: 80, align: 'left' },
                { label: '学生身份证号', name: 'IDNumber', width: 150, align: 'left' },
                {
                    label: '住房类型', name: 'HouseFlag', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["HouseFlag"][cellvalue] == undefined ? "" : top.clients.dataItems["HouseFlag"][cellvalue]
                    }
                },
                {
                    label: '第一志愿学校', name: 'SchoolId', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.schoolItems[cellvalue] == undefined ? "" : top.clients.schoolItems[cellvalue].schoolName
                    }
                },
                {
                    label: '第二志愿学校', name: 'SecondSchoolId', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.schoolItems[cellvalue] == undefined ? "" : top.clients.schoolItems[cellvalue].schoolName
                    }
                },
                {
                    label: '年级', name: 'Class', width: 50, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["Class"][cellvalue] == undefined ? "" : top.clients.dataItems["Class"][cellvalue]
                    }
                },
                {
                    label: '家庭情况照片', name: 'Pic_FamilySituation', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgFamilySituation' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: '学生家庭情况', name: 'FamilySituation', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        return (top.clients.dataItems["FamilySituation"][cellvalue] == undefined || top.clients.dataItems["FamilySituation"][cellvalue] == "请选择") ? "" : top.clients.dataItems["FamilySituation"][cellvalue]
                    }
                },
                { label: '父亲姓名', name: 'FatherName', width: 80, align: 'left' },
                { label: '父亲联系方式', name: 'FatherPhone', width: 100, align: 'left' },
                { label: '父亲身份证号', name: 'FatherIDNumber', width: 150, align: 'left' },
                { label: '母亲姓名', name: 'MotherName', width: 80, align: 'left' },
                { label: '母亲联系方式', name: 'MotherPhone', width: 100, align: 'left' },
                { label: '母亲身份证号', name: 'MotherIDNumber', width: 150, align: 'left' },
                {
                    label: '户口属地', name: 'HouseHoldPosition', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["HouseHoldPosition"][cellvalue] == undefined ? "" : top.clients.dataItems["HouseHoldPosition"][cellvalue]
                    }
                },
                { label: '户主姓名', name: 'HouseHolderName', width: 80, align: 'left' },
                {
                    label: '户主与学生关系', name: 'HouseHolderRelation', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return (top.clients.dataItems["HouseHolderRelation"][cellvalue] == undefined || top.clients.dataItems["HouseHolderRelation"][cellvalue] == "请选择") ? "" : top.clients.dataItems["HouseHolderRelation"][cellvalue]
                    }
                },
                {
                    label: '户口本户主照片', name: 'Pic_HouseHold', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgHouseHold' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: '户口本学生本人页照片', name: 'Pic_HouseHoldStudent', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgHouseHoldStudent' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: '户口本索引页照片', name: 'Pic_HouseHoldIndex', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgHouseHoldIndex' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: '学生父母结婚证照片', name: 'Pic_MarriageCertificate', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgMarriageCertificate' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: '学生出生证明照片', name: 'Pic_BirthCertification', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgBirthCertification' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                { label: 'A_1_房证产权人姓名', name: 'A_CertificateName', width: 300, align: 'left' },
                { label: 'A_1_房证产权人身份证号', name: 'A_CertificateIDNumber', width: 300, align: 'left' },
                { label: 'A_1_房证上登记地址', name: 'A_CertificateAddress', width: 420, align: 'left' },
                {
                    label: 'A_1_房权证照片', name: 'Pic_A_Certificate', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgA_Certificate' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'A_1_房屋所有权人与学生关系', name: 'A_CertificateRelation', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return (top.clients.dataItems["A_CertificateRelation"][cellvalue] == undefined || top.clients.dataItems["A_CertificateRelation"][cellvalue] == "请选择") ? "" : top.clients.dataItems["A_CertificateRelation"][cellvalue]
                    }
                },
                { label: 'A_2_购房人姓名', name: 'A_CertificateName2', width: 300, align: 'left' },
                { label: 'A_2_购房人身份证号', name: 'A_CertificateIDNumber2', width: 300, align: 'left' },
                { label: 'A_2_购房合同登记地址', name: 'A_CertificateAddress2', width: 420, align: 'left' },
                {
                    label: 'A_2_购房合同照片1', name: 'Pic_A_Contract', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgA_Contract' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'A_2_购房合同照片2', name: 'Pic_A_Contract1', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgA_Contract1' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'A_2_购房合同照片3', name: 'Pic_A_Contract2', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgA_Contract2' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'A_2_购房合同照片4', name: 'Pic_A_Contract3', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgA_Contract3' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'A_2_购房合同照片5', name: 'Pic_A_Contract4', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgA_Contract4' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'A_2_全款发票照片', name: 'Pic_A_Receipt', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgA_Receipt' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                { label: 'B_1_租房地址', name: 'C_RentAddress', width: 420, align: 'left' },
                {
                    label: 'B_1_房管局备案的租赁合同照片', name: 'Pic_C_RentContract', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgC_RentContract' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'B_1_父亲务工合同照片', name: 'Pic_C_MaleLaborContract_IN', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgC_MaleLaborContract_IN' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'B_1_母亲务工合同照片', name: 'Pic_C_FemaleLaborContract_IN', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgC_FemaleLaborContract_IN' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                { label: 'B_2_现居住地址', name: 'C_RentAddress1', width: 420, align: 'left' },
                {
                    label: 'B_2_父亲居住证照片', name: 'Pic_C_ResidencePermit', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgC_ResidencePermit' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'B_2_母亲居住证照片', name: 'Pic_C_FemaleResidencePermit', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgC_FemaleResidencePermit' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'B_2_父亲务工合同照片', name: 'Pic_C_MaleLaborContract_OUT', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgC_MaleLaborContract_OUT' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                {
                    label: 'B_2_母亲务工合同照片', name: 'Pic_C_FemaleLaborContract_OUT', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return (cellvalue == undefined || cellvalue == "") ? "" : "<img id='ImgC_FemaleLaborContract_OUT' src='" + cellvalue + "?" + version + "' style=' width: 200px; height: 100px;cursor:pointer' onclick='largePic(this)'/>"
                    }
                },
                { label: '住房所属大类', name: 'HouseClass', width: 150, align: 'left' },
                { label: '学生原所在学校全称', name: 'OriginalSchool', width: 150, align: 'left' },
                { label: '其他说明', name: 'Remark', width: 300, align: 'left'},
                {
                    label: '审核结果', name: 'OStatus', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        if (top.clients.dataItems["schoolOStatus"][cellvalue] != undefined) {
                            return top.clients.dataItems["schoolOStatus"][cellvalue];
                        }
                        if (top.clients.dataItems["studentOStatus"][cellvalue] != undefined) {
                            return top.clients.dataItems["studentOStatus"][cellvalue];
                        }
                        if (top.clients.dataItems["eduOStatus"][cellvalue] != undefined) {
                            return top.clients.dataItems["eduOStatus"][cellvalue];
                        }
                    }
                },
            ],
            sortname: 'F_CreatorTime asc',
            viewrecords: true,
            onCellSelect: function (data, row) {
            },
            loadComplete: function (xhr) {
                if (0 == xhr.rows.length) {
                    $("#NF-delete").css("display", "none");
                    $("#NF-edit").css("display", "none");
                    $("#NF-info").css("display", "none");
                }
                if (xhr.rows.length > 0) {//如果是预录取或者录取状态，当前数据不可删除和修改
                    operFid = xhr.rows[0]['F_Id'];
                    operOStatus = xhr.rows[0]['OStatus'];
                    if ('4' == xhr.rows[0]['OStatus'] || '5' == xhr.rows[0]['OStatus']) {
                        $("#NF-delete").css("display", "none");
                        $("#NF-edit").css("display", "none");
                    }
                }
                if ("3" != xhr.submitStatus) {
                    bootbox.alert("提交状态已关闭，当前申请资料不可删除或者修改");
                    $("#NF-delete").css("display", "none");
                    $("#NF-edit").css("display", "none");
                    $("#addApplyDiv").css("display", "none");
                }
            }
        });
    }
    //新增资料申请
    function btn_add() {
        $.ajax({
            url: "/Gas/Apply/CheckData",
            dataType: "json",
            async: false,
            success: function (data) {
                if (0 == data.TotalCount) {
                    window.location.href = "/Gas/Apply/RegisterForm";
                } else {
                    bootbox.alert("资料只能申请一次，如需变更请选择修改，或者删除后重新申请！");
                }
            }
        });
    }
    function btn_update() {
        if ('4' == operOStatus || '5' == operOStatus ) {
            bootbox.alert("资料已审核通过（预录取或者录取状态不可修改）");
            return;
        }
        if (operFid == null || operFid == "") {
            bootbox.alert("请选择想要更新的申请");
            return;
        } else {
            window.location.href = "/Gas/Apply/Update?keyValue=" + operFid;
        }
    }
    function btn_details() {
        if (operFid == null || operFid == "") {
            bootbox.alert("请选择想要查看的申请");
            return;
        } else {
            window.location.href = "/Gas/Apply/Details?keyValue=" + operFid;
        }
    }
    function btn_delete() {
        if (operFid == null || operFid == "") {
            bootbox.alert("请选择想要删除的申请");
            return;
        }
        if ('4' == operOStatus || '5' == operOStatus) {
            bootbox.alert("资料已审核通过（预录取或者录取状态不可删除）");
            return;
        }
        $.deleteForm({
            url: "/Gas/Apply/DeleteForm",
            param: { keyValue: operFid },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div id="detailDiv" class="btn-group">
            <a id="NF-info" class="btn btn-primary" onclick="btn_details()"><i class="fa fa-info"></i>&nbsp;详情</a>
        </div>
        <div id="deleteDiv" class="btn-group">
            <a id="NF-delete" class="btn btn-primary" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
        </div>
        <div id="updateDiv" class="btn-group">
            <a id="NF-edit" class="btn btn-primary" onclick="btn_update()"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
        </div>
        <div id="addApplyDiv" class="btn-group">
            <a class="btn btn-primary" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增申请</a>
        </div>
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
<div id="my-modal" class="modal fade" data-placement="center" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<div id="outerdiv" style="position:fixed;top:0;left:200px;background:rgba(0,0,0,0.7);z-index:2000;display:none;">
    <div id="innerdiv" style="position:absolute;width: 200%;height:200%;">
        <img id="bigimg" style="border:5px solid #fff;width: 800px;height:600px;" src="" />
    </div>
</div>